package com.jml.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import java.util.Random;

 
@Service
@Slf4j
@RocketMQMessageListener(consumerGroup = "jml-group20", topic = "topic_seq", consumeMode = ConsumeMode.ORDERLY
)
public class RocketMQConsumer01 implements RocketMQListener<String> {
    @Override
    public void onMessage(String msg) {
        // msgid 消息详细信息
        try {
            Random r = new Random(100);
            int i = r.nextInt(500);
            Thread.sleep(i);
        } catch (Exception e) {

        }
        log.info("消费者监听到消息：<msg:{}>", msg);
    }
}
